//
//  LTView.m
//  DoubanProject
//
//  Created by 花磊 on 15/5/13.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "LTView.h"
#import "UILabel+Additional.h"
#import "UITextField+Additional.h"
@implementation LTView

- (void)dealloc
{
    [_label release];
    [_textField release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame labelDescription:(NSString *)labelDescription placeholder:(NSString *)placeholder security:(BOOL)security {
    
    return [self initWithFrame:frame labelDescription:labelDescription placeholder:placeholder security:security keyboardType:(UIKeyboardTypeDefault)];
}

- (instancetype)initWithFrame:(CGRect)frame labelDescription:(NSString *)labelDescription placeholder:(NSString *)placeholder security:(BOOL)security keyboardType:(UIKeyboardType)keyboardType {
    
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat width = frame.size.width;
        CGFloat height = frame.size.height;
        CGFloat x = 0;
        CGFloat y = 0;
        _label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width / 4, height) text:labelDescription alignment:NSTextAlignmentLeft];
        
        CGFloat textFieldX = x + width / 4;
        CGFloat textFieldWidth = width * 3 / 4 - 5;
        _textField = [[UITextField alloc] initWithFrame:CGRectMake(textFieldX, y, textFieldWidth , height) placeholder:placeholder security:security borderStyle:UITextBorderStyleNone keyboardType:keyboardType];
        [self addSubview:_label];
        [self addSubview:_textField];
    }
    return self;
}

- (void)setText:(NSString *)text {
    
    _textField.text = text;
}
- (NSString *)text {
    
    return _textField.text;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
